package com.java83.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.java83.dto.impl.OneDto;
import com.java83.dto.impl.TwoDto;
import com.java83.entity.Employee;
import com.java83.entity.Leaving;
import com.java83.response.ResponseEntity;
import com.java83.service.LeaveManagementService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author ytg
 * @version 1.0.0
 * @ClassName LeaveManagementController
 * @Description 离职管理
 * @createTime 2021年12月14日 14:43:00
 */
@RestController
@RequestMapping("/leaveManagement")
public class LeaveManagementController {

    @Resource
    LeaveManagementService leaveManagementService;


    /**
     * 分页条件查询
     * @param dto 分页 条件(员工，离职)
     * @return 查询结果
     */
    @RequestMapping("/findByLimit")

    public ResponseEntity<PageInfo<Map<String,Object>>> findByLimit(@RequestBody TwoDto<Employee, Leaving> dto){
        PageHelper.startPage(dto.getPage(),dto.getLimit());
        return new ResponseEntity(200, "查询成功",new PageInfo<>(leaveManagementService.findByLimit(dto.getData1(), dto.getData2())) );
    }
}
